<template>
    <!-- 合同公司 -->
    <el-form-item :label-width="item.labelWidth?item.labelWidth:'130px'" :label="item.title" :prop="rules?item.field:''">
      <span slot="label">{{item.title}}
        <el-tooltip v-if="item.info" :content="item.info" placement="top">
          <span class="fas fa-info-circle color"></span>
        </el-tooltip>
      </span>
      <el-select @change="change"  v-model="form[item.field]" :disabled="disabled" filterable placeholder="请选择" style="width: 100%;">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.name"
          :value="item.value">
        </el-option>
      </el-select>
    </el-form-item>
</template>

<script>
import { findAllCommpany } from '../../../api/common';
// import store from '@/store'
export default {
  props: ['item', 'form', 'rules', 'disabled', 'isParams', 'paramsId'],
  data() {
    return {
      list: [],
      options: []
    };
  },
  mounted: function() {
    findAllCommpany().then(respose => {
      // console.log(respose);
      if (respose.success) {
        this.options = [];
        if (respose.list) {
          respose.list.forEach(v => {
            const obj = {
              name: v.companyName,
              value: v.code
            };
            this.options.push(obj);
            // console.log(this.options);
          });
        }
      }
    });
    if (this.item.init) {
      this.item.init(this.form, this.item);
    }
  },
  methods: {
    change(v) {
      if (this.item.itemChange) {
        this.item.itemChange(this.form, this.item, v);
      }
    }
  }
};
</script>

